	<?php
		$this->paginate['Category'] =array('conditions' => 'Category.pid=0',
										'limit' => 10,
										'order'=>'Category.id ASC'
									  );
		$Categories = $this->paginate('Category');
		
		if(isset($Categories) and ($Categories))
			{
				$x=0;
				foreach($Categories as $Categoy)
				{
					$parent_cat_result = $this->_get_parent_cat($Categoy['Category']['id']);
					$Categories[$x]['Category']['ParentType'] = $parent_cat_result; 
					$subcats = $this->_get_subcatecategories($Categoy['Category']['id'], "");
					$Categories[$x]['Category']['subcats'] = $subcats; 
							$t=0;
								foreach($subcats as $subcat)
									{
										$subcat_cat = $this->_get_subcatecategories($subcat['Category']['id'], "");
										$Categories[$x]['Category']['subcats'][$t]['Category']['Sub'] = $subcat_cat; 
										$b=0;
											foreach($subcat_cat as $subcat_catsubcat)
												{
													$subcat_catsubcatsubcat_cat = $this->_get_subcatecategories($subcat_catsubcat['Category']['id'], "");
													$Categories[$x]['Category']['subcats'][$t]['Category']['Sub'][$b]['Category']['Sub_SubCats'] 
													= $subcat_catsubcatsubcat_cat; 
													$b++;
												}
										$t++;
									}
					$x++;
				}
			}
?>

View Code........

<div id="mws-container" class="clearfix">
  <div class="container">
    <div class="mws-panel grid_8">
      <div class="mws-panel-header"> <span class="mws-i-24 i-table-1" style="width:100%;">Category - Management
        <div class="fr" style="width:20%; float:right; "> <?php echo $html->link('Add Category', array('action'=>'admin_addcategory'), array('style'=>'width:70%;color:#fff;'));?> </div>
        </span> </div>
      <div class="mws-panel-body">
        <div class="dataTables_wrapper">
          <table class="mws-datatable-fn mws-table">
            <thead>
              <tr>
                <th class="sorting_asc" rowspan="1" colspan="1" style="width: 141px;">Category Name</th>
                <th class="sorting" rowspan="1" colspan="1" style="width: 254px;">Category Image</th>
                <th class="sorting" rowspan="1" colspan="1" style="width: 254px;">Category Parent</th>
                <th class="sorting" rowspan="1" colspan="1" style="width: 239px;">Category Slug</th>
                <th class="sorting" rowspan="1" colspan="1" style="width: 150px;">Category Status</th>
                <th class="sorting" rowspan="1" colspan="1" style="width: 91px;">Options</th>
              </tr>
            </thead>
            <?php if(isset($Category) and ($Category)): ?>
            <tbody>
              <?php  $x =1; foreach($Category as $Cat){
				?>
              <tr class="gradeA odd">
                <td class=" sorting_1"><?php echo  $x.'__'.$Cat['Category']['name']; ?></td>
                <td><?php 
				if(isset($Cat['Category']['img']) and ($Cat['Category']['img']))
					{
						echo $html->image('Category/'.$Cat['Category']['img'], array('width'=>'50', 'height'=>'50'));
					}
				
				 ?></td>
                <td><?php echo $Cat['Category']['ParentType']; ?></td>
                <td><?php echo $Cat['Category']['slug']; ?></td>
                <td class="center"><?php if(isset($Cat['Category']['status']) and ($Cat['Category']['status']==1)){echo "Active";}else{ echo "Deactive";} ?></td>
                <td class="center"><?php 
                echo $html->link("Edit", 
                array('action'=>'admin_addcategory',"Category", 
                base64_encode($Cat['Category']['id'])), array('escape'=>false));  
            ?>
                  <?php
					 echo $html->link('Delete',
					 array('controller'=>'Setups', 'action' => 'admin_delete_by_id',
					'Category',$Cat['Category']['id'],'categories'), array('escape' => false,'id'=>'alink'), 'Are you sure?');
			  ?></td>
              </tr>
					  <?php foreach($Cat['Category']['subcats'] as $Cat_subcats){ ?>
                      <tr class="gradeA odd">
                        <td class=" sorting_1">&nbsp;&nbsp;__<?php echo $Cat_subcats['Category']['name']; ?></td>
                        <td><?php 
                        if(isset($Cat_subcats['Category']['img']) and ($Cat_subcats['Category']['img']))
                            {
                                echo $html->image('Category/'.$Cat_subcats['Category']['img'], array('width'=>'50', 'height'=>'50'));
                            }
                        
                         ?></td>
                        <td><?php echo "Children"; ?></td>
                        <td><?php echo $Cat_subcats['Category']['slug']; ?></td>
                        <td class="center"><?php if(isset($Cat_subcats['Category']['status']) and ($Cat_subcats['Category']['status']==1)){echo "Active";}else{ echo "Deactive";} ?></td>
                        <td class="center"><?php 
                        echo $html->link("Edit", 
                        array('action'=>'admin_addcategory',"Category", 
                        base64_encode($Cat_subcats['Category']['id'])), array('escape'=>false));  
                    ?>
                          <?php
                             echo $html->link('Delete',
                             array('controller'=>'Setups', 'action' => 'admin_delete_by_id',
                            'Category',$Cat_subcats['Category']['id'],'categories'), array('escape' => false,'id'=>'alink'), 'Are you sure?');
                      ?></td>
                      </tr>
                              <?php foreach($Cat_subcats['Category']['Sub'] as $Cat_subcats_subcats){ ?>
                              <tr class="gradeA odd">
                                <td class=" sorting_1">&nbsp;&nbsp;&nbsp;&nbsp;__<?php echo $Cat_subcats_subcats['Category']['name']; ?></td>
                                <td><?php 
                                            if(isset($Cat_subcats_subcats['Category']['img']) and ($Cat_subcats_subcats['Category']['img']))
                                                {
                                                    echo $html->image('Category/'.$Cat_subcats_subcats['Category']['img'], array('width'=>'50', 'height'=>'50'));
                                                }
                                            
                                             ?></td>
                                <td><?php echo "Children"; ?></td>
                                <td><?php echo $Cat_subcats_subcats['Category']['slug']; ?></td>
                                <td class="center"><?php if(isset($Cat_subcats_subcats['Category']['status']) and ($Cat_subcats_subcats['Category']['status']==1)){echo "Active";}else{ echo "Deactive";} ?></td>
                                <td class="center"><?php 
                                            echo $html->link("Edit", 
                                            array('action'=>'admin_addcategory',"Category", 
                                            base64_encode($Cat_subcats_subcats['Category']['id'])), array('escape'=>false));  
                                        ?>
                                  <?php
                                                 echo $html->link('Delete',
                                                 array('controller'=>'Setups', 'action' => 'admin_delete_by_id',
                                                'Category',$Cat_subcats_subcats['Category']['id'],'categories'), array('escape' => false,'id'=>'alink'), 'Are you sure?');
                                          ?></td>
                              </tr>
                                          <?php foreach($Cat_subcats_subcats['Category']['Sub_SubCats'] as $Cat_subcats_subcats_Sub_SubCats){ ?>
                                                <tr class="gradeA odd">
                                            <td class=" sorting_1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__<?php echo $Cat_subcats_subcats_Sub_SubCats['Category']['name']; ?></td>
                                            <td><?php 
                                                                if(isset($Cat_subcats_subcats_Sub_SubCats['Category']['img']) and ($Cat_subcats_subcats_Sub_SubCats['Category']['img']))
                                                                    {
                                                                        echo $html->image('Category/'.$Cat_subcats_subcats_Sub_SubCats['Category']['img'], array('width'=>'50', 'height'=>'50'));
                                                                    }
                                                                
                                                                 ?></td>
                                            <td><?php echo "Children"; ?></td>
                                            <td><?php echo $Cat_subcats_subcats_Sub_SubCats['Category']['slug']; ?></td>
                                            <td class="center"><?php if(isset($Cat_subcats_subcats_Sub_SubCats['Category']['status']) and ($Cat_subcats_subcats_Sub_SubCats['Category']['status']==1)){echo "Active";}else{ echo "Deactive";} ?></td>
                                            <td class="center"><?php 
                                                                echo $html->link("Edit", 
                                                                array('action'=>'admin_addcategory',"Category", 
                                                                base64_encode($Cat_subcats_subcats_Sub_SubCats['Category']['id'])), array('escape'=>false));  
                                                            ?>
                                              <?php
                                                                     echo $html->link('Delete',
                                                                     array('controller'=>'Setups', 'action' => 'admin_delete_by_id',
                                                                    'Category',$Cat_subcats_subcats_Sub_SubCats['Category']['id'],'categories'), array('escape' => false,'id'=>'alink'), 'Are you sure?');
                                                              ?></td>
                                          </tr>
                                          <?php } ?>
                              <?php } ?>
                      <?php } ?>
              <?php $x++;} ?>
            </tbody>
            <?php endif; ?>
          </table>
          <div class="dataTables_info">Showing 1 to 10 of 57 entries</div>
          <div class="dataTables_paginate paging_full_numbers"> <?php echo $this->element('paging'); ?> </div>
        </div>
      </div>
    </div>
  </div>
</div>
